<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:clickframes="http://" xml:lang="en" lang="en">
<head>
    <title>Entity Documentation - ${appspec.title}</title>
	<link rel="stylesheet" type="text/css" href="css/reset-fonts-sans.css" />
	<link rel="stylesheet" type="text/css" href="css/grid-12-fluid.css" />
    <link rel="stylesheet" type="text/css" href="css/style-entities.css" />
    <style type="text/css" media="screen">
        body {
            margin:2em;
        }
        
        .entity-page {
            margin-bottom:6em;
        }
        
        .toc {
            background:#eeeeee;
            padding-top:2em;
            padding-bottom:2em;
        }
        
        .page-space {
            display:none;
        }
    </style>
</head>
<body>

<div class="container_12 entity-page toc">
    
    <div class="prefix_1 grid_11 toc_title">
        <h2>${appspec.title}</h2>
        <h1>Entity Documentation</h1>
        <h3>8 April 2010</h3>
        <h4>Generated by Clickframes</h4>
    </div>
    <div class="clear"></div>
    
    #foreach($entity in $appspec.entities)
    <div class="grid_1 toc_page">${velocityCount}</div>
    <div class="grid_11 toc_description"><a href="#${entity.id}">${entity.title}</a></div>
    <div class="clear"></div>
    #end
    
    <div class="prefix_1 grid_11 toc_title">
        <h3><strong>Legend</strong></h3>
    </div>
    
    <div class="grid_1 toc_page"><u>x</u></div>
    <div class="grid_11 toc_description">Primary Key</div>
    <div class="clear"></div>
    
    <div class="grid_1 toc_page">*</div>
    <div class="grid_11 toc_description">Maximum occurrences unbounded</div>
    <div class="clear"></div>
    
    <div class="grid_1 toc_page">[x]</div>
    <div class="grid_11 toc_description">Transient</div>
    <div class="clear"></div>
    
</div>
<div class="page-space">&nbsp;</div>

#foreach($entity in $appspec.entities)
<div class="container_12 entity-page">

    <div class="grid_2 page-number">
        <a name="${entity.id}">${velocityCount}</a>
    </div>
    <div class="grid_10 header">
        <h1>${entity.title}</h1>
        <h2>${entity.description}</h2>
    </div>
    <div class="clear"></div>
    
    <div class="prefix_2 grid_10">
    <table class="entity-properties">
#foreach($property in $entity.properties)
    <tr class="property">
        <th>
#if ($property.primaryKey)
            <u>${property.title}</u>
#elseif (!$property.persistent)
            [${property.title}]
#else
            ${property.title}
#end
#if ($property.multiple)
            *
#end
        </th>
        <td>
            <p class="entity-description">
                #if ($property.description)
                ${property.description}
                #else
                No description.
                #end
            </p>
            <table>
                <tr>
                    <th>ID</th>
                    <td>${property.id}</td>
                </tr>
                <tr>
                    <th>Type</th>
                    <td>
                        ${property.type.name}
#if ($property.type == 'ENTITY')
                        &ndash; <a href="#${property.foreignEntity.id}">${property.foreignEntity.title}</a>
#end
                    </td>
                </tr>
#if ($property.defaultValue)
                <tr>
                    <th>Default</th>
                    <td>${property.defaultValue}</td>
                </tr>
#end
#if ($property.positiveExample)
                <tr>
                    <th>Positive Example</th>
                    <td>${property.positiveExample}</td>
                </tr>
#end
#if ($property.allowedValues.size() > 0)
                <tr>
                    <th>Allowed Values</th>
                    <td>
#foreach ($entry in $property.allowedValues.entrySet())
                        <div class="allowedValue">${entry.key} &raquo; <strong>${entry.value}</strong></div>
#end
                    </td>
                </tr>
#end
#if ($property.validations.size() > 0)
                <tr>
                    <th>Validations</th>
                    <td>
#foreach ($validation in $property.validations)
#if ($validation.type == "required")
                        <div class="validation">Required</div>
#elseif ($validation.type == "length")
                        <div class="validation">Length ${validation.typeArgs}</div>
#elseif ($validation.type == "regex")
                        <div class="validation">Regular Expression ${validation.typeArgs}</div>
#elseif ($validation.type == "email")
                        <div class="validation">E-mail Address</div>
#elseif ($validation.type == "url")
                        <div class="validation">URL</div>
#else
                        <div class="validation">$validation.type</div>
#end
#end
                    </td>
                </tr>
#end
            </table>
        </td>
    </tr>
#end
    </table>
    </div>
    <div class="clear"></div>
    <div class="page-space">&nbsp;</div>
    
</div>
<div class="page-space">&nbsp;</div>
#end

</body>
</html>